Skip to content

feat(hass): add domain-aware intent mapping and prefix detection#50

Open
cmac86 wants to merge 2 commits intomainfrom
feat/enhance-hass-tools
Open

feat(hass): add domain-aware intent mapping and prefix detection#50
cmac86 wants to merge 2 commits intomainfrom
feat/enhance-hass-tools

Conversation

@cmac86
Copy link
Member

@cmac86 cmac86 commented Feb 6, 2026

Summary

Fixes #47 — Enhances Home Assistant integration with domain-aware intent mapping and automatic tool prefix detection.

  • Extract to module — Moves HA logic from voice_agent.py to src/caal/integrations/hass.py, following existing pattern (n8n.py, web_search.py)
  • Prefix detection — Auto-detects assist__ prefix at startup for compatibility with different HA MCP servers (official vs community)
  • Device cache — Parses GetLiveContext to map device names to domains (cover, climate, light, etc.) with 5-minute TTL
  • Domain-aware routing — Routes commands to correct intents: covers use HassOpenCover/HassCloseCover, climate uses HassClimateSetTemperature, lights use HassLightSet
  • New actionsopen, close, toggle, set_brightness, set_temperature, stop

Intent Mapping

Action Domain Intent
turn_on/turn_off cover HassOpenCover / HassCloseCover
open/close cover HassOpenCover / HassCloseCover
stop cover HassStopMoving
set_brightness light HassLightSet
set_temperature climate HassClimateSetTemperature
turn_on/turn_off * HassTurnOn / HassTurnOff (fallback)

Test plan

  • Unit tests pass (device cache parsing, device lookup, intent mapping)
  • Smoke test: turn on/off lights and media controls still work
  • Smoke test: hass_get_state returns device info
  • Integration test with assist__ prefixed HA MCP server (VESCreative)
  • Integration test with cover devices (open/close garage door)
  • Integration test with climate devices (set thermostat temperature)

🤖 Generated with Claude Code

@cmac86
Copy link
Member Author

cmac86 commented Feb 6, 2026

Testing Instructions

for localhost

git fetch origin
git checkout feat/enhance-hass-tools
docker compose up --build -d

or for remote server

git fetch origin
git checkout feat/enhance-hass-tools
docker compose --profile https up --build -d

Check startup logs

docker logs caal-agent 2>&1 | grep -i "prefix\|Home Assistant"

Expected if using assist__ prefix:

Home Assistant MCP uses 'assist__' prefix
Home Assistant tools enabled: hass_control, hass_get_state

Test matrix

Command Expected
"turn on the office lamp" Works as before (backward compat)
"open the garage door" HassOpenCover not HassTurnOn
"close the garage door" HassCloseCover not HassTurnOff
"stop the garage door" HassStopMoving
"set thermostat to 72" HassClimateSetTemperature
"set bedroom lights to 50 percent" HassLightSet

Debug mode (optional)

In voice_agent.py line 74, set _caal_logger.setLevel(logging.DEBUG) to see inner MCP tool calls, device cache hits, and prefix application.

Full testing details on #47.

cmac86 and others added 2 commits February 7, 2026 11:25
Extract Home Assistant integration into dedicated module with:
- Automatic detection of MCP tool prefixes (assist__ vs bare names)
- Device cache with domain information from GetLiveContext
- Domain-specific intent mapping (cover -> HassOpenCover, not HassTurnOn)
- New actions: open, close, toggle, set_brightness, set_temperature, stop

Fixes #47

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When LLM sends set_volume for a light entity, remap to set_brightness.
Catches common model confusion between set_volume/set_brightness/
set_temperature based on the actual device domain from the cache.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cmac86 cmac86 force-pushed the feat/enhance-hass-tools branch from 7b007aa to b0d2838 Compare February 7, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Possible Home Assistant Integration problem

1 participant